Real estate in Zürich

the Zürich Statistical Office collects data on the city and its residents. This data is published as Linked Data.

In this tutorial, we will show how to work with Linked Data. Mainly, we will see how to work with the real estate dataset.
We will look into how to query, process, and visualize it.

1. Housing prices
      1.1 Prices per apartment type
      1.2 Prices per district
      1.3 Prices per district and apartment type
      1.4 Prices over time
      1.5 Prices over time for various apartment types
2. Apartments and population growth
3. Apartment types over time

SPARQL endpoint

Data on the real estate market is published as Linked Data. It can be accessed with SPARQL queries.
You can send queries using HTTP requests. The API endpoint is https://ld.stadt-zuerich.ch/query/.

Let's use SparqlClient from graphly to communicate with the database. Graphly will allow us to:

SPARQL queries can become very long. To improve the readibility, we will work wih prefixes.

Using the add_prefixes method, we define persistent prefixes. Every time you send a query, graphly will automatically add the prefixes for you.

Housing prices

Let's find the average price per m2 for an apartment in Zurich. This data is available in the QMP-EIG-HAA-OBJ-ZIM data cube. It will allow us to find the price per city district and apartment type. The data is also available for different points in time.

The query for housing prices in city of Zürich for different districts and apartment types over time looks as follows:

Prices per apartment type

Let's visualize the housing prices per apartment type. To do this, we will aggregate the prices per rooms.
The cleaned dataframe becomes:

Prices per district

Let's visualize the housing prices per district. To do this, we will aggregate the prices per place.
The cleaned dataframe becomes:

Prices per district and apartment type

Now, let's combine both views. We will visualize housing prices across districts and apartment types.
The dataframe for plotting becomes:

City districts

drawing

Prices over time

Let's take a look at averge housing prices over time. We will aggregate the results by time.
Here is the dataframe and the graph:

Prices over time for various apartment types

Now that we have seen the trend, let's dig a bit deeper. We will visualize housing prices over time for 2, 4 and 6-room apartments. To achieve this, we need to reshape our dataframe to show prices per apartment type over time.

The reshaped dataframe becomes:

Apartments and population growth

Real estate prices are influenced by:

Let's take a look at how those numbers evolved over time. Mainly, we want find the apartments and population count in city of Zurich.

The query for the number of inhabitants and apartments over time looks as follows:

Apartment types over time

Let's take a look at what apartments were, and are available in Zurich. How did the share of various apparmnent types evolve over time? Is there a trend to build more smaller (or bigger) apartments? These insights are available in the WHG-ZIM data cube.

The query for the number of different apartment types over time looks as follows:

Let's reshape our dataframe to show the apartment count per apartment type, over time: